import React from "react";
import store from "@/store";
import { incrementCount } from "../../store/actions/countActions";
import { decrementCount } from "../../store/actions/countActions";
import { delayIncrementCount } from "../../store/actions/countActions";
export default function Count() {
  console.log("在Count中打印获取的store", store);
  console.log("在Count中打印获取的store的值", store.getState());
  return (
    <div>
      <h1>Count组件</h1>
      <p>count的值是{store.getState().count}</p>
      <div>
        <h1>Count组件</h1>
        <p>movie电影的列表长度是:{store.getState().movie.movieList.length}</p>
        <p>count的值是{store.getState().count}</p>
        <button
          onClick={() => {
            store.dispatch(incrementCount());
            // console.log(store.getState());
          }}
        >
          累加1
        </button>
        <button
          onClick={() => {
            store.dispatch(decrementCount());
            // console.log(store.getState());
          }}
        >
          累减1
        </button>
        <button
          onClick={() => {
            store.dispatch(incrementCount(2));
            // console.log(store.getState());
          }}
        >
          累加2
        </button>
        <button
          onClick={() => {
            store.dispatch(decrementCount(2));
            // console.log(store.getState());
          }}
        >
          累减2
        </button>
        <button
          onClick={() => {
            store.dispatch(delayIncrementCount(2));
            // console.log(store.getState());
          }}
        >
          延迟两秒累加2
        </button>
      </div>
    </div>
  );
}
